﻿#pragma once

#include "MLibrary.h"
#include "FixedListView.h"
#include <string>
#include <unordered_map>
#include <vector>
#include <any>
#include <cstdint>
#include "../stringhelper.h"
#include "../tangible_filesystem.h"

namespace LibraryViewer
{
    class LMain : public System::Windows::Forms::Form
    {
    private:
//C# TO C++ CONVERTER WARNING: C++ has no equivalent to a 'readonly' collection which allows modification of internal state:
//ORIGINAL LINE: private readonly Dictionary<int, int> _indexList = new Dictionary<int, int>();
        std::unordered_map<int, int> _indexList = std::unordered_map<int, int>();
        std::vector<Bitmap*> _LImageList = std::vector<Bitmap*>();
        std::vector<std::string> _NameList = std::vector<std::string>();
        MLibrary *_library;
        std::string folderName = "";
        bool showFrontSide = false;

//C# TO C++ CONVERTER NOTE: The following .NET DllImport attribute was converted using the Microsoft-specific __declspec(dllimport):
//[DllImport("user32.dll")]
        __declspec(dllimport) static int SendMessage(std::intptr_t hWnd, int msg, int wParam, int lParam);
    public:
        virtual ~LMain()
        {
            delete _library;
            delete components;
            delete MainMenu;
            delete fileToolStripMenuItem;
            delete openMenuItem;
            delete ImageList;
            delete LibraryFolderDialog;
            delete splitContainer1;
            delete splitContainer2;
            delete checkCenter;
            delete checkBackground;
            delete HeightLabel;
            delete LblHeight;
            delete LibCountLabel;
            delete WidthLabel;
            delete LblLibCount;
            delete LblWidth;
            delete ImageBox;
            delete PreviewListView;
            delete LibNameLabel;
            delete LblLibName;
            delete DebugBox;
            delete ExportImagesButton;
        }

        LMain();

    private:
        void ClearInterface();

        void openToolStripMenuItem_Click(std::any sender, EventArgs *e);

        void PreviewListView_SelectedIndexChanged(std::any sender, EventArgs *e);

        void PreviewListView_RetrieveVirtualItem(std::any sender, RetrieveVirtualItemEventArgs *e);

        void checkBackground_CheckedChanged(std::any sender, System::EventArgs *e);

        void checkCenter_CheckedChanged(std::any sender, System::EventArgs *e);

        void ExportImagesButton_Click(std::any sender, EventArgs *e);


        /// <summary>
        /// Required designer variable.
        /// </summary>
        System::ComponentModel::IContainer *components = nullptr;

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
    protected:
        void Dispose(bool disposing) override;

        #pragma region Windows Form Designer generated code

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
    private:
        void InitializeComponent();

        #pragma endregion

        System::Windows::Forms::MenuStrip *MainMenu;
        System::Windows::Forms::ToolStripMenuItem *fileToolStripMenuItem;
        System::Windows::Forms::ToolStripMenuItem *openMenuItem;
        System::Windows::Forms::ImageList *ImageList;
        System::Windows::Forms::FolderBrowserDialog *LibraryFolderDialog;
        System::Windows::Forms::SplitContainer *splitContainer1;
        System::Windows::Forms::SplitContainer *splitContainer2;
        System::Windows::Forms::CheckBox *checkCenter;
        System::Windows::Forms::CheckBox *checkBackground;
        System::Windows::Forms::Label *HeightLabel;
        System::Windows::Forms::Label *LblHeight;
        System::Windows::Forms::Label *LibCountLabel;
        System::Windows::Forms::Label *WidthLabel;
        System::Windows::Forms::Label *LblLibCount;
        System::Windows::Forms::Label *LblWidth;
        System::Windows::Forms::PictureBox *ImageBox;
        FixedListView *PreviewListView;
        System::Windows::Forms::Label *LibNameLabel;
        System::Windows::Forms::Label *LblLibName;
        System::Windows::Forms::TextBox *DebugBox;
        System::Windows::Forms::Button *ExportImagesButton;
    };
}
